import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '@views/Home'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/home',
    name: 'home',
    component: Home,
    //meta路由源信息
    meta: {
      isNeedLogin: false
    }
  },
  {
    path: '/cates',
    name: 'cates',
    //路由懒加载
    component: () => import('@views/Cates'),
    meta: {
      isNeedLogin: false
    }
  },
  {
    path: '/cart',
    name: 'cart',
    component: () => import('@views/Cart'),
    meta: {
      isNeedLogin: false
    }
  },
  {
    path: '/mine',
    name: 'mine',
    component: () => import('@views/Mine'),
    meta: {
      isNeedLogin: true
    }
  },
  {
    path: '/detail',
    name: 'detail',
    component: () => import('@views/Detail'),
    meta: {
      isNeedLogin: false
    }
  },
  {
    path: '/itemLists/:categoryId',
    name: 'itemLists',
    component: () => import('@views/ItemLists'),
    meta: {
      isNeedLogin: false
    }
  },
  {
    path: '/order',
    name: 'order',
    component: () => import('@views/Order'),
    meta: {
      isNeedLogin: true
    }
  },
  {
    path: '/login',
    name: 'login',
    component: () => import('@views/Login'),
    meta: {
      isNeedLogin: false
    }
  },
  {
    path: '/contactAdd',
    name: 'contactAdd',
    component: () => import('@views/ContactAdd'),
    meta: {
      isNeedLogin: true
    }
  },
  {
    path: '/contactLists',
    name: 'contactLists',
    component: () => import('@views/ContactLists'),
    meta: {
      isNeedLogin: true
    }
  },
  {
    path: '/search',
    name: 'search',
    component: () => import('@views/Search'),
    meta: {
      isNeedLogin: false
    }
  },
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})
export default router
